
#ifndef TRIANGULATOR_H
#define TRIANGULATOR_H

// INCLUDES ********************************************************************

#include <vector>

// FORWARD DECLARATIONS ********************************************************

namespace Meteor 
{
    class Vector2D;
}



// *****************************************************************************

//! Triangulator
//! 
//! Auxiliary class used by TexturedPolygon to calculate the texture 
//! coordinates used to map a texture onto the polygon. This class is based on
//! code provided by John W. Ratcliff. See implementation file for more info

// *****************************************************************************

namespace Meteor
{
    class Triangulator
    {
        public:
            static bool Process( const std::vector<Vector2D>& contour, 
                                 std::vector<Vector2D>& result);
            
        private:
            static float Area( const std::vector<Vector2D>& contour);
        
            static bool Snip( const std::vector<Vector2D>& contour, 
                              int u, 
                              int v, 
                              int w, 
                              int n, 
                              int* V);
            
            // decide if point Px/Py is inside triangle defined by
            // (Ax,Ay) (Bx,By) (Cx,Cy)
            static bool InsideTriangle( float Ax, float Ay,
                                        float Bx, float By,
                                        float Cx, float Cy,
                                        float Px, float Py);

    }; // end of class Triangulator
    
} // end of namespace Meteor

#endif
